#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using XNALibrary.Game;
using XNALibrary.Entities;
using XNALibrary.Cameras;
using XNALibrary.Lighting;
using XNALibrary.Materials;
using XNALibrary.Skybox;
using XNALibrary.PostProcessing;
#endregion

namespace Test2
{
    public class Game : BaseGame
    {
        private Entity beast1;
        private Entity model;
        private Entity beast2;
        private float angle;

        public Game()
            : base()
        {
        }

        protected override void Init()
        {
            beast1 = new Entity();
            beast1.RotationX(-(float)Math.PI / 2);
            beast2 = new Entity();
            beast2.RotationX(-(float)Math.PI / 2);
            beast2.Position = new Vector3(500, 0, 0);
            //model = new Entity();
            //model.RotationX((float)Math.PI / 2);
            camera = new FreeCamera(new Vector3(0, 0, 30));
            ((FreeCamera)camera).Lookat = Vector3.Zero;
            ((FreeCamera)camera).NearPlane = 1.0f;
            ((FreeCamera)camera).FarPlane = 100000f;
            ((FreeCamera)camera).Speed = 300f;
            ((FreeCamera)camera).TurnSpeed = 30;

            BackgroundColor = Color.Black;

            skybox = new Skybox(Skybox.SkyboxType.Street);

            depthOfField.Active = true;
            depthOfField.DepthMap.MaxDepth = 1000;

            //postProcessing = new PostProcessingManager();
            //postProcessing.AddFilter(new SaturateFilter(0, 0.2f));
            //postProcessing.AddFilter(new GaussianBlurFilter(1, GaussianBlurFilter.Direction.Horizontal));
            //postProcessing.AddFilter(new GaussianBlurFilter(2, GaussianBlurFilter.Direction.Vertical));
            //postProcessing.AddFilter(new CombineFilter(0, 3, CombineFilter.Techniques.SUM));
        }

        protected override void LoadContent()
        {
            //model.LoadModel(Entity.Primitives.Skullocc, new PerPixelLighting());//new EnviromentMap(skybox.Type));
            //model.LoadModel(Entity.Primitives.Skullocc, new DepthMap());
            beast1.LoadModel("Content/Models/Beast", new OnlyTexture());
            beast2.LoadModel("Content/Models/Beast2", new OnlyTexture());

            scene.Add(beast1);
            scene.Add(beast2);
            //scene.Add(model);
        }

        protected override void UpdateGame()
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.Escape))
                this.Exit();

            ((FreeCamera)camera).Update();
            //angle += 0.02f;
            //model.RotationY(angle);
        }
    }
}
